package com.zzyl.nursing.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zzyl.nursing.dto.NursingTaskDto;
import com.zzyl.nursing.dto.TaskDto;
import com.zzyl.nursing.vo.NursingTaskVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.nursing.domain.NursingTask;
import com.zzyl.nursing.service.INursingTaskService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 护理任务Controller
 *
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/nursing/nursingTask")
@Api(tags = "护理任务的接口")
@Slf4j
public class NursingTaskController extends BaseController {
    @Autowired
    private INursingTaskService nursingTaskService;

    /**
     * 查询护理任务列表
     */
    @ApiOperation("查询护理任务列表")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:list')")
    @GetMapping("/list")
    public TableDataInfo list(NursingTaskDto nursingTaskDto) {
        log.info("查询护理任务列表");
        TableDataInfo tableDataInfo = nursingTaskService.selectNursingTaskList(nursingTaskDto);
        return tableDataInfo;
    }


    /**
     * 获取护理任务详细信息
     */
    @ApiOperation("获取护理任务详细信息")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        log.info("获取护理任务详细信息");
        return success(nursingTaskService.getInfo(id));
    }


    /**
     * 取消任务
     */
    @ApiOperation("取消任务")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:cancel')")
    @PutMapping("/cancel")
    public AjaxResult cancel(@RequestBody @ApiParam("取消任务") TaskDto taskDto) {
        log.info("取消任务");
        return toAjax(nursingTaskService.cancel(taskDto));
    }

    /**
     * 执行任务
     */
    @ApiOperation("执行任务")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:do')")
    @PutMapping("/do")
    public AjaxResult doTask(@RequestBody @ApiParam("执行任务") TaskDto taskDto) {
        log.info("执行任务");
        return toAjax(nursingTaskService.doTask(taskDto));
    }

    /**
     * 任务改期
     */
    @ApiOperation("任务改期")
    @PreAuthorize("@ss.hasPermi('nursing:nursingTask:do')")
    @PutMapping("/updateTime")
    public AjaxResult updateTimeTask(@RequestBody @ApiParam("任务改期") TaskDto taskDto){
        log.info("任务改期");
        return toAjax(nursingTaskService.updateTimeTask(taskDto));
    }


}
